//
//  SportNumber.m
//  PlayBall
//
//  Created by Huawen Liu on 12-6-28.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddSportNumber.h"

@implementation JddSportNumber

@synthesize teamArray;
@synthesize Hteam;
@synthesize Vteam;
@synthesize code;
@synthesize endTime;
@synthesize isSingle;

- (id)init{
    self = [super init];
    
    if (self) {
        self.teamArray = [NSMutableArray array];
    }
    
    return self;
}

- (NSInteger)addBallNumber:(NSInteger)number{
    [teamArray addObject:[NSNumber numberWithInt:number]];    
    return [teamArray count];
}

- (NSInteger)removeBallNumber:(NSInteger)number{
    for (NSNumber *inNumber in teamArray) {
        if ([inNumber intValue] == number) {
            [teamArray removeObject:inNumber];
            break;
        }
    }
    
    return [teamArray count];
}


- (void)clear{
    [teamArray removeAllObjects];
}

- (BOOL)BallHasNumber:(NSInteger)number{
    for (NSNumber *inNumber in teamArray) {
        if ([inNumber intValue] == number) {
            return YES;
        }
    }
    
    return NO;	
}
//zbj add

//根据给出的宽度和字符串，动态计算该字符串所需长度
- (CGFloat)customHeight:(CGFloat)width font:(NSInteger)font
{
    //获得系统版本号
    CGFloat sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];
    
    CGFloat height = 0.0;
    if (sysVer >= 7.0) {
        
        //字符串显示时的字体
        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:font],NSFontAttributeName, nil];
        
        height = [self.titleStr boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dict context:NULL].size.height;
    } else {
        //根据字符串的内容，要显示的字体，和显示的宽度计算字符串的高度
        height=[self.titleStr sizeWithFont:[UIFont systemFontOfSize:font] constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByCharWrapping].height;
    }
    return height;
}
//根据给出的宽度和字符串，动态计算该字符串所需长度
- (CGFloat)customWidth:(CGFloat)height font:(NSInteger)font
{
    //获得系统版本号
    CGFloat sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];
    
    CGFloat width = 0.0;
    if (sysVer >= 7.0) {
        
        //字符串显示时的字体
        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:font],NSFontAttributeName, nil];
        
        width = [self.titleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height) options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:dict context:NULL].size.width;
    } else {
        //根据字符串的内容，要显示的字体，和显示的宽度计算字符串的高度
        width = [self.titleStr sizeWithFont:[UIFont systemFontOfSize:font] constrainedToSize:CGSizeMake(CGFLOAT_MAX, height) lineBreakMode:NSLineBreakByCharWrapping].width;
    }
    return width;
}


@end
